'use strict';

const BaseService = require('./base');

class AreaService extends BaseService {
  get _model() {
    return 'Area';
  }

  async findOne({ id }) {
    const where = this.formatWhere({ exact: { id } });
    return this._findOne({ where });
  }

  async create({ name, level, parentId }) {
    return this._create({
      name, level, parentId,
    });
  }

  async update({ name, id }) {
    const body = { name };
    const where = { id };
    return this._update({ body, where });
  }

  async findAll() {
    return this._findAll();
  }

  async destory(id) {
    const where = { id };
    return this._destory({ where });
  }
}

module.exports = AreaService;
